package com.kurumi.service.impl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kurumi.config.MyConfig;
import com.kurumi.mapper.MedicalRecordMapper;
import com.kurumi.pojo.MedicalRecordPageIndex2016;
import com.kurumi.pojo.coding.DiseaseDiagRecord;
import com.kurumi.query.MedicalRecordQuery;
import com.kurumi.service.MedicalRecordPageIndexService;
import com.kurumi.util.JsonUtil;
import com.kurumi.util.ObjectUtils;
import com.kurumi.util.StringUtil;
@Service
public class MedicalRecordPageIndexServiceImpl implements MedicalRecordPageIndexService {

	@Autowired
	private MedicalRecordMapper medicalRecordMapper;

	@Autowired
	private MyConfig myConfig;

	@Override
	public List<MedicalRecordPageIndex2016> getMedicalRecordPageIndex2016(MedicalRecordQuery medicalRecordQuery) {
		// TODO Auto-generated method stub
		List<MedicalRecordPageIndex2016> pageIndexs = new ArrayList<MedicalRecordPageIndex2016>();
		List<Map<String, Object>> medicalRecords = medicalRecordMapper.getMedicalRecordOfCheck(medicalRecordQuery);
		/*List<Map<String, Object>> medicalDepts = baseInfoMapper.getAllMedicalDepts();
		Map<String,String> medicalDeptMap = new HashMap<String,String>();
		for (Map<String, Object> medicalDept : medicalDepts) {
			String code = ObjectUtils.getStringValue(medicalDept.get("code"));
			String refCode = ObjectUtils.getStringValue(medicalDept.get("ref_code"));
			if(refCode != null){
				if(medicalDeptMap.get(code)==null){
					medicalDeptMap.put(code, refCode);
				}
			}

		}*/
		for (Map<String, Object> medicalRecord : medicalRecords) {
			MedicalRecordPageIndex2016 pageIndex = new MedicalRecordPageIndex2016();

			pageIndexs.add(pageIndex);

			String visitGuid = (String)medicalRecord.get("visit_guid");
			pageIndex.setVisitGuid(visitGuid);
			List<String> jsonDatas = medicalRecordMapper.getMedicalRecordJsonByVisitGuid(StringUtil.handleJsonParam(visitGuid));

			if(!jsonDatas.isEmpty()){

				Map<String, Object> jsonMap = JsonUtil.jsonToPojo(jsonDatas.get(0), Map.class);
				Map<String, Object> basicInfo = (Map<String, Object>)jsonMap.get("basicInfo");
				if(basicInfo != null){
					String orgCode = ObjectUtils.getStringValue(basicInfo.get("hospitalCode"));
					String orgName = ObjectUtils.getStringValue(basicInfo.get("hospitalName"));;
					if(orgCode == null){
						orgCode = myConfig.getOrgCode();
					}
					if(orgName == null){
						orgName = myConfig.getOrgName();
					}
					pageIndex.setOrgCode(orgCode);
					pageIndex.setOrgName(orgName);
					String onlyId = ObjectUtils.getStringValue(basicInfo.get("onlyId"));
					pageIndex.setOnlyId(onlyId);
					String outDeptCode = ObjectUtils.getStringValue(basicInfo.get("outDeptCode"));
					/*if(outDeptCode!=null && medicalDeptMap.get(outDeptCode)!=null){
						outDeptCode = medicalDeptMap.get(outDeptCode);
					}*/
					pageIndex.setOutDeptCode(outDeptCode);
					String outDeptName = ObjectUtils.getStringValue(basicInfo.get("outDeptName"));
					pageIndex.setOutDeptName(outDeptName);

					String outHospitalTypeCode = ObjectUtils.getStringValue(basicInfo.get("outHospitalTypeCode"));
					pageIndex.setOutHospitalTypeCode(outHospitalTypeCode);
					String outHospitalTypeName = ObjectUtils.getStringValue(basicInfo.get("outHospitalTypeName"));
					pageIndex.setOutHospitalTypeName(outHospitalTypeName);

					String medicalInsuranceNumber = ObjectUtils.getStringValue(basicInfo.get("medicalInsuranceNumber"));
					pageIndex.setMedicalInsuranceNumber(medicalInsuranceNumber);
					String medicalHealthNumber = ObjectUtils.getStringValue(basicInfo.get("medicalHealthNumber"));
					pageIndex.setMedicalHealthNumber(medicalHealthNumber);
					String medicalPayTypeCode = ObjectUtils.getStringValue(basicInfo.get("medicalPayTypeCode"));
					pageIndex.setMedicalPayTypeCode(medicalPayTypeCode);
					Integer visitNumber = ObjectUtils.getIntegerValue(basicInfo.get("visitNumber"));
					pageIndex.setVisitNumber(visitNumber);
					String mrId = ObjectUtils.getStringValue(basicInfo.get("mrId"));
					pageIndex.setMrId(mrId);
					String patientName = ObjectUtils.getStringValue(basicInfo.get("patientName"));
					pageIndex.setPatientName(patientName);
					String sexCode = ObjectUtils.getStringValue(basicInfo.get("sexCode"));
					pageIndex.setSexCode(sexCode);
					Date birthday = ObjectUtils.getDateValue(basicInfo.get("birthday"));
					pageIndex.setBirthday(birthday);
					Integer yearOfAge = ObjectUtils.getIntegerValue(basicInfo.get("yearOfAge"));
					pageIndex.setYearOfAge(yearOfAge);
					String marriageCode = ObjectUtils.getStringValue(basicInfo.get("marriageCode"));
					pageIndex.setMarriageCode(marriageCode);
					String professionCode = ObjectUtils.getStringValue(basicInfo.get("professionCode"));
					pageIndex.setProfessionCode(professionCode);
					Map<String,Object> birthRegionalism = (Map<String,Object>)basicInfo.get("birthRegionalism");
					if(birthRegionalism!= null){
						String provinceCode = ObjectUtils.getStringValue(birthRegionalism.get("provinceCode"));
						String cityCode = ObjectUtils.getStringValue(birthRegionalism.get("cityCode"));
						String provinceName = ObjectUtils.getStringValue(birthRegionalism.get("provinceName"));
						String cityName = ObjectUtils.getStringValue(birthRegionalism.get("cityName"));

						pageIndex.setProvinceNameOfBirthAddress(provinceName);
						pageIndex.setCityNameOfBirthAddress(cityName);
						String countyCode = ObjectUtils.getStringValue(birthRegionalism.get("countyCode"));
						String countyName = ObjectUtils.getStringValue(birthRegionalism.get("countyName"));
						pageIndex.setCountyNameOfBirthAddress(countyName);
					}
					String nationalityCode = ObjectUtils.getStringValue(basicInfo.get("nationalityCode"));
					String nationalityName = ObjectUtils.getStringValue(basicInfo.get("nationalityName"));
					pageIndex.setNationalityCode(nationalityCode);
					String nationCode = ObjectUtils.getStringValue(basicInfo.get("nationCode"));
					String nationName = ObjectUtils.getStringValue(basicInfo.get("nationName"));
					pageIndex.setNationCode(nationCode);
					String idNumber = ObjectUtils.getStringValue(basicInfo.get("idNumber"));
					pageIndex.setIdNumber(idNumber);
					String permanentAddress = ObjectUtils.getStringValue(basicInfo.get("permanentAddress"));
					pageIndex.setPermanentAddress(permanentAddress);
					String permanentAddressPhone = ObjectUtils.getStringValue(basicInfo.get("permanentAddressPhone"));
					pageIndex.setPermanentAddressPhone(permanentAddressPhone);
					String permanentAddressPostCode = ObjectUtils.getStringValue(basicInfo.get("permanentAddressPostCode"));
					pageIndex.setPermanentAddressPostCode(permanentAddressPostCode);

					String workUnitAddress = ObjectUtils.getStringValue(basicInfo.get("workUnitAddress"));
					pageIndex.setWorkUnitNameAndAddress(workUnitAddress);
					String workUnitPhone = ObjectUtils.getStringValue(basicInfo.get("workUnitPhone"));
					pageIndex.setWorkUnitPhone(workUnitPhone);
					String workUnitPostCode = ObjectUtils.getStringValue(basicInfo.get("workUnitPostCode"));
					pageIndex.setWorkUnitPostCode(workUnitPostCode);

					String registeredAddress = ObjectUtils.getStringValue(basicInfo.get("registeredAddress"));
					pageIndex.setRegisteredAddress(registeredAddress);
					String registeredAddressPostCode = ObjectUtils.getStringValue(basicInfo.get("registeredAddressPostCode"));
					pageIndex.setRegisteredAddressPostCode(registeredAddressPostCode);

					String linkManName = ObjectUtils.getStringValue(basicInfo.get("linkManName"));
					pageIndex.setLinkManName(linkManName);
					String linkManRelativeRelationCode = ObjectUtils.getStringValue(basicInfo.get("linkManRelativeRelationCode"));
					String linkManRelativeRelationName = ObjectUtils.getStringValue(basicInfo.get("linkManRelativeRelationName"));
					pageIndex.setLinkManRelativeRelationName(linkManRelativeRelationName);
					String linkManAddress = ObjectUtils.getStringValue(basicInfo.get("linkManAddress"));
					pageIndex.setLinkManAddress(linkManAddress);
					String linkManPhone = ObjectUtils.getStringValue(basicInfo.get("linkManPhone"));
					pageIndex.setLinkManPhone(linkManPhone);

					String inHospitalTypeCode = ObjectUtils.getStringValue(basicInfo.get("inHospitalTypeCode"));
					pageIndex.setInHospitalTypeCode(inHospitalTypeCode);
					String inHospitalTypeName = ObjectUtils.getStringValue(basicInfo.get("inHospitalTypeName"));
					Date inHospitalDateTime = ObjectUtils.getDateTimeValue(basicInfo.get("inHospitalDateTime"));
					pageIndex.setInHospitalDateTime(inHospitalDateTime);
					String inDeptCode = ObjectUtils.getStringValue(basicInfo.get("inDeptCode"));
					/*if(inDeptCode!=null && medicalDeptMap.get(inDeptCode)!=null){
						inDeptCode = medicalDeptMap.get(inDeptCode);
					}*/
					pageIndex.setInDeptCode(inDeptCode);
					String inDeptName = ObjectUtils.getStringValue(basicInfo.get("inDeptName"));
					String inHospitalHouseName = ObjectUtils.getStringValue(basicInfo.get("inHospitalHouseName"));
					pageIndex.setInHospitalHouseName(inHospitalHouseName);
					Date outHospitalDateTime = ObjectUtils.getDateTimeValue(basicInfo.get("outHospitalDateTime"));
					pageIndex.setOutHospitalDateTime(outHospitalDateTime);
					String outHospitalHouseName = ObjectUtils.getStringValue(basicInfo.get("outHospitalHouseName"));
					pageIndex.setOutHospitalHouseName(outHospitalHouseName);

					Integer inHospitalDayNumber = ObjectUtils.getIntegerValue(basicInfo.get("inHospitalDayNumber"));
					pageIndex.setInHospitalDayNumber(inHospitalDayNumber);
					String changeDeptDesc = ObjectUtils.getStringValue(basicInfo.get("changeDeptDesc"));
					pageIndex.setChangeDeptCodes(changeDeptDesc);
					String drugAllergyDesc = ObjectUtils.getStringValue(basicInfo.get("drugAllergyDesc"));
					pageIndex.setAllergyDrugNames(drugAllergyDesc);
					String isAutopsyCode = ObjectUtils.getStringValue(basicInfo.get("autopsyCode"));
					String isAutopsyName = ObjectUtils.getStringValue(basicInfo.get("autopsyName"));
					pageIndex.setIsAutopsyCode(isAutopsyCode);
					if(outHospitalTypeCode != null){
						String receiveUnitName = ObjectUtils.getStringValue(basicInfo.get("receiveUnitName"));
						if("2".equals(outHospitalTypeCode)){
							pageIndex.setReceiveUnitNameOfTransferHospital(receiveUnitName);
						}else if("3".equals((String)outHospitalTypeCode)){
							pageIndex.setReceiveUnitNameOfTransferCommunity(receiveUnitName);
						}
					}
				}
				Map<String, Object> cureInfo = (Map<String, Object>)jsonMap.get("cureInfo");
				if(cureInfo != null){
					String hbsAgResultCode = ObjectUtils.getStringValue(cureInfo.get("hbsAgeResultCode"));
					String hbsAgResultName = ObjectUtils.getStringValue(cureInfo.get("hbsAgeResultName"));
					pageIndex.setHbsAgResultCode(hbsAgResultCode);

					String hcvAbResultCode = ObjectUtils.getStringValue(cureInfo.get("hcvAbResultCode"));
					String hcvAbResultName = ObjectUtils.getStringValue(cureInfo.get("hcvAbResultName"));
					pageIndex.setHcvAbResultCode(hcvAbResultCode);
					String hivAbResultCode = ObjectUtils.getStringValue(cureInfo.get("hivAbResultCode"));
					String hivAbResultName = ObjectUtils.getStringValue(cureInfo.get("hivAbResultName"));
					pageIndex.setHivAbResultCode(hivAbResultCode);

					List<Map<String, Object>> diagAccordRecords = (List<Map<String, Object>>)cureInfo.get("diagAccordRecords");
					for (Map<String, Object> diagAccordRecord : diagAccordRecords) {

						String diagCompareCode = ObjectUtils.getStringValue(diagAccordRecord.get("diagCompareCode"));
						String diagAccordCode = ObjectUtils.getStringValue(diagAccordRecord.get("diagAccordCode"));
						String diagAccordName = ObjectUtils.getStringValue(diagAccordRecord.get("diagAccordName"));
						if(diagCompareCode != null){
							if("A01".equalsIgnoreCase(diagCompareCode)){
								pageIndex.setDiagAccordA01CompareCode(diagAccordCode);
							}else if("A02".equalsIgnoreCase(diagCompareCode)){
								pageIndex.setDiagAccordA02CompareCode(diagAccordCode);
							}else if("A03".equalsIgnoreCase(diagCompareCode)){
								pageIndex.setDiagAccordA03CompareCode(diagAccordCode);
							}else if("A04".equalsIgnoreCase(diagCompareCode)){
								pageIndex.setDiagAccordA04CompareCode(diagAccordCode);
							}else if("A05".equalsIgnoreCase(diagCompareCode)){
								pageIndex.setDiagAccordA05CompareCode(diagAccordCode);
							}
						}
					}
					Integer rescueNumber =ObjectUtils.getIntegerValue(cureInfo.get("rescueNumber"));
					pageIndex.setRescueTimes(rescueNumber);

					Integer rescueSucceedNumber = ObjectUtils.getIntegerValue(cureInfo.get("rescueSucceedNumber"));
					pageIndex.setRescueSucceedTimes(rescueSucceedNumber);
					String malignantTumorHighestDiagBasisCode =ObjectUtils.getStringValue(cureInfo.get("malignantTumorHighestDiagBasisCode"));
					String malignantTumorHighestDiagBasisName =ObjectUtils.getStringValue(cureInfo.get("malignantTumorHighestDiagBasisName"));
					pageIndex.setMalignantTumorHighestDiagBasisCode(malignantTumorHighestDiagBasisCode);

					String malignantTumorDifferentDegreeCode = ObjectUtils.getStringValue(cureInfo.get("malignantTumorDifferentDegreeCode"));
					String malignantTumorDifferentDegreeName = ObjectUtils.getStringValue(cureInfo.get("malignantTumorDifferentDegreeName"));
					pageIndex.setMalignantTumorDifferentDegreeCode(malignantTumorDifferentDegreeCode);
					List<Map<String, Object>> cureWorkers = (List<Map<String, Object>>)cureInfo.get("cureWorkers");

					for (Map<String, Object> cureWorker : cureWorkers) {
						String professionTitleCode = ObjectUtils.getStringValue(cureWorker.get("professionTitleCode"));
						String medicalWorkerName = ObjectUtils.getStringValue(cureWorker.get("medicalWorkerName"));
						if("A1001".equals(professionTitleCode)){
							pageIndex.setA1001DoctorName(medicalWorkerName);
						}else if("A2001".equals(professionTitleCode)){
							pageIndex.setA2001DoctorName(medicalWorkerName);
						}else if("A2003".equals(professionTitleCode)){
							pageIndex.setA2003DoctorName(medicalWorkerName);
						}else if("A2005".equals(professionTitleCode)){
							pageIndex.setA2005DoctorName(medicalWorkerName);
						}else if("A3001".equals(professionTitleCode)){
							pageIndex.setA3001DoctorName(medicalWorkerName);
						}else if("A2006".equals(professionTitleCode)){
							pageIndex.setA2006DoctorName(medicalWorkerName);
						}else if("A2007".equals(professionTitleCode)){
							pageIndex.setA2007DoctorName(medicalWorkerName);
						}else if("A2008".equals(professionTitleCode)){
							pageIndex.setA2008DoctorName(medicalWorkerName);
						}else if("A4001".equals(professionTitleCode)){
							pageIndex.setA4001DoctorName(medicalWorkerName);
						}else if("A2009".equals(professionTitleCode)){
							pageIndex.setA2009DoctorName(medicalWorkerName);
						}else if("A3003".equals(professionTitleCode)){
							pageIndex.setA3003DoctorName(medicalWorkerName);
						}
					}
					String medicalRecordQualityCode = ObjectUtils.getStringValue(cureInfo.get("medicalRecordQualityCode"));
					String medicalRecordQualityName = ObjectUtils.getStringValue(cureInfo.get("medicalRecordQualityName"));
					pageIndex.setMedicalRecordQualityCode(medicalRecordQualityCode);
					Date qualityControlDateTime = ObjectUtils.getDateTimeValue(cureInfo.get("qualityControlDateTime"));
					pageIndex.setQualityControlDateTime(qualityControlDateTime);

					String isFirstCaseCode = ObjectUtils.getStringValue(cureInfo.get("isFirstCaseCode"));
					String isFirstCaseName = ObjectUtils.getStringValue(cureInfo.get("isFirstCaseName"));
					pageIndex.setIsFirstCaseCode(isFirstCaseCode);
					String isFollowUpClinicCode = ObjectUtils.getStringValue(cureInfo.get("followUpClinicLimitCode"));
					String isFollowUpClinicName = ObjectUtils.getStringValue(cureInfo.get("followUpClinicLimitName"));
					pageIndex.setIsFollowUpClinicCode(isFollowUpClinicCode);
					BigDecimal followUpClinicWeekNumber =ObjectUtils.getBigDecimalValue(cureInfo.get("followUpClinicWeekNumber"));
					pageIndex.setFollowUpClinicWeekNumber(followUpClinicWeekNumber);
					BigDecimal followUpClinicMonthNumber = ObjectUtils.getBigDecimalValue(cureInfo.get("followUpClinicMonthNumber"));
					pageIndex.setFollowUpClinicMonthNumber(followUpClinicMonthNumber);
					BigDecimal followUpClinicYearNumber = ObjectUtils.getBigDecimalValue(cureInfo.get("followUpClinicYearNumber"));
					pageIndex.setFollowUpClinicYearNumber(followUpClinicYearNumber);
					String isTeachingCaseCode = ObjectUtils.getStringValue(cureInfo.get("isTeachingCaseCode"));
					String isTeachingCaseName = ObjectUtils.getStringValue(cureInfo.get("isTeachingCaseName"));
					pageIndex.setIsTeachingCaseCode(isTeachingCaseCode);
					String bloodTypeCode = ObjectUtils.getStringValue(cureInfo.get("bloodTypeCode"));
					String bloodTypeName = ObjectUtils.getStringValue(cureInfo.get("bloodTypeName"));
					pageIndex.setBloodTypeCode(bloodTypeCode);
					String rhBloodTypeCode = ObjectUtils.getStringValue(cureInfo.get("rhBloodTypeCode"));
					String rhBloodTypeName = ObjectUtils.getStringValue(cureInfo.get("rhBloodTypeName"));
					pageIndex.setRhBloodTypeCode(rhBloodTypeCode);
					Integer monthOfAge = ObjectUtils.getIntegerValue(basicInfo.get("monthOfAge"));
					Integer dayOfAge = ObjectUtils.getIntegerValue(basicInfo.get("dayOfAge"));

					if(monthOfAge == null){
						if(dayOfAge!= null){
							float month = dayOfAge/30f;
							pageIndex.setMonthOfAge(new BigDecimal(month).setScale(2, BigDecimal.ROUND_HALF_UP));
						}
					}else{
						pageIndex.setMonthOfAge(new BigDecimal(""+monthOfAge));
					}


					Integer babyBirthWeight = ObjectUtils.getIntegerValue(cureInfo.get("babyBirthWeight"));
					pageIndex.setBabyBirthWeight(babyBirthWeight);

					Integer babyInHospitalWeight = ObjectUtils.getIntegerValue(cureInfo.get("babyInHospitalWeight"));
					pageIndex.setBabyInHospitalWeight(babyInHospitalWeight);
					Integer hourOfBeforeInHospitalComa = ObjectUtils.getIntegerValue(cureInfo.get("hourOfBeforeInHospitalComa"));
					pageIndex.setHourOfBeforeInHospitalComa(hourOfBeforeInHospitalComa);
					Integer minuteOfBeforeInHospitalComa = ObjectUtils.getIntegerValue(cureInfo.get("minuteOfBeforeInHospitalComa"));
					pageIndex.setMinuteOfBeforeInHospitalComa(minuteOfBeforeInHospitalComa);
					Integer hourOfAfterInHospitalComa = ObjectUtils.getIntegerValue(cureInfo.get("hourOfAfterInHospitalComa"));
					pageIndex.setHourOfAfterInHospitalComa(hourOfAfterInHospitalComa);
					Integer minuteOfAfterInHospitalComa = ObjectUtils.getIntegerValue(cureInfo.get("minuteOfAfterInHospitalComa"));
					pageIndex.setMinuteOfAfterInHospitalComa(minuteOfAfterInHospitalComa);
					String rehospitalAimOf31Code =ObjectUtils.getStringValue(cureInfo.get("rehospitalAimOf31Code"));
					String rehospitalAimOf31Name =ObjectUtils.getStringValue(cureInfo.get("rehospitalAimOf31Name"));
					pageIndex.setIsRehospitalAfter31DayPlanCode(rehospitalAimOf31Code);

					String rehospitalAimOf31Description = ObjectUtils.getStringValue(cureInfo.get("rehospitalAimOf31Description"));
					pageIndex.setRehospitalAfter31DayAimName(rehospitalAimOf31Description);



				}

				Map<String, Object> diseaseDiagInfo = (Map<String, Object>)jsonMap.get("hqmsDiseaseDiagInfo");
				if(diseaseDiagInfo != null){
					DiseaseDiagRecord diagRecord = new DiseaseDiagRecord();
					Map<String, Object> outpatientDiagRecord = (Map<String, Object>)diseaseDiagInfo.get("outpatientDiagRecord");
					if(outpatientDiagRecord != null){
						String outpatientDiagCode =  ObjectUtils.getStringValue(outpatientDiagRecord.get("diseaseDiagCode"));
						if("无".equalsIgnoreCase(outpatientDiagCode)){
							outpatientDiagCode = null;
						}
						pageIndex.setOutpatientDiagCode(outpatientDiagCode);
						String outpatientDiagName =  ObjectUtils.getStringValue(outpatientDiagRecord.get("diseaseDiagName"));
						if("无".equalsIgnoreCase(outpatientDiagName)){
							outpatientDiagName = null;
						}
						pageIndex.setOutpatientDiagName(outpatientDiagName);
					}
					Map<String, Object> mainDiagRecord = (Map<String, Object>)diseaseDiagInfo.get("mainDiagRecord");
					if(mainDiagRecord != null){
						String mainDiagCode =  ObjectUtils.getStringValue(mainDiagRecord.get("diseaseDiagCode"));
						pageIndex.setMainDiagCode(mainDiagCode);
						String mainDiagName =  ObjectUtils.getStringValue(mainDiagRecord.get("diseaseDiagName"));
						pageIndex.setMainDiagName(mainDiagName);
						String inHospitalDiseaseStateCode =  ObjectUtils.getStringValue(mainDiagRecord.get("inHospitalDiseaseStateCode"));
						String inHospitalDiseaseStateName =  ObjectUtils.getStringValue(mainDiagRecord.get("inHospitalDiseaseStateName"));
						String treatResultCode =  ObjectUtils.getStringValue(mainDiagRecord.get("treatResultCode"));

						String treatResultName =  ObjectUtils.getStringValue(mainDiagRecord.get("treatResultName"));
						pageIndex.setMainDiagAdmissionConditionCode(inHospitalDiseaseStateCode);
						pageIndex.setMainDiagTreatResultCode(treatResultCode);

					}
					List<Map<String, Object>> ohterDiseaseDiagRecords = (List<Map<String, Object>>)diseaseDiagInfo.get("diseaseDiagRecords");
					int otherDiagRecordIndex = 0;
					for (Map<String, Object> otherDiagRecord : ohterDiseaseDiagRecords) {
						otherDiagRecordIndex++;
						String otherDiagCode =  ObjectUtils.getStringValue(otherDiagRecord.get("diseaseDiagCode"));
						if("无".equalsIgnoreCase(otherDiagCode)){
							otherDiagCode = null;
						}
						String otherDiagName =  ObjectUtils.getStringValue(otherDiagRecord.get("diseaseDiagName"));
						if("无".equalsIgnoreCase(otherDiagName)){
							otherDiagName = null;
						}
						String inHospitalDiseaseStateCode =  ObjectUtils.getStringValue(otherDiagRecord.get("inHospitalDiseaseStateCode"));
						String inHospitalDiseaseStateName =  ObjectUtils.getStringValue(otherDiagRecord.get("inHospitalDiseaseStateName"));
						String treatResultCode =  ObjectUtils.getStringValue(otherDiagRecord.get("treatResultCode"));
						String treatResultName =  ObjectUtils.getStringValue(otherDiagRecord.get("treatResultName"));
						if(otherDiagRecordIndex == 1){
							pageIndex.setOtherDiag1Code(otherDiagCode);
							pageIndex.setOtherDiag1Name(otherDiagName);
							pageIndex.setOtherDiag1AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag1TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 2){
							pageIndex.setOtherDiag2Code(otherDiagCode);
							pageIndex.setOtherDiag2Name(otherDiagName);
							pageIndex.setOtherDiag2AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag2TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 3){
							pageIndex.setOtherDiag3Code(otherDiagCode);
							pageIndex.setOtherDiag3Name(otherDiagName);
							pageIndex.setOtherDiag3AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag3TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 4){
							pageIndex.setOtherDiag4Code(otherDiagCode);
							pageIndex.setOtherDiag4Name(otherDiagName);
							pageIndex.setOtherDiag4AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag4TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 5){
							pageIndex.setOtherDiag5Code(otherDiagCode);
							pageIndex.setOtherDiag5Name(otherDiagName);
							pageIndex.setOtherDiag5AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag5TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 6){
							pageIndex.setOtherDiag6Code(otherDiagCode);
							pageIndex.setOtherDiag6Name(otherDiagName);
							pageIndex.setOtherDiag6AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag6TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 7){
							pageIndex.setOtherDiag7Code(otherDiagCode);
							pageIndex.setOtherDiag7Name(otherDiagName);
							pageIndex.setOtherDiag7AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag7TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 8){
							pageIndex.setOtherDiag8Code(otherDiagCode);
							pageIndex.setOtherDiag8Name(otherDiagName);
							pageIndex.setOtherDiag8AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag8TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 9){
							pageIndex.setOtherDiag9Code(otherDiagCode);
							pageIndex.setOtherDiag9Name(otherDiagName);
							pageIndex.setOtherDiag9AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag9TreatResultCode(treatResultCode);
						}else if(otherDiagRecordIndex == 10){
							pageIndex.setOtherDiag10Code(otherDiagCode);
							pageIndex.setOtherDiag10Name(otherDiagName);
							pageIndex.setOtherDiag10AdmissionConditionCode(inHospitalDiseaseStateCode);
							pageIndex.setOtherDiag10TreatResultCode(treatResultCode);
						}
					}
					List<Map<String, Object>> pathologyDiagRecords = (List<Map<String, Object>>)diseaseDiagInfo.get("pathologyDiagRecords");
					int pathologyDiagRecordIndex = 0;
					for (Map<String, Object> pathologyDiagRecord : pathologyDiagRecords) {
						pathologyDiagRecordIndex++;
						String otherDiagCode =  ObjectUtils.getStringValue(pathologyDiagRecord.get("diseaseDiagCode"));
						String otherDiagName =  ObjectUtils.getStringValue(pathologyDiagRecord.get("diseaseDiagName"));
						String pathologyNumber =  ObjectUtils.getStringValue(pathologyDiagRecord.get("pathologyNumber"));
						if(pathologyDiagRecordIndex == 1){
							pageIndex.setPathologyDiag1Code(otherDiagCode);
							pageIndex.setPathologyDiag1Name(otherDiagName);
							pageIndex.setPathologyNumber1(pathologyNumber);
						}else if(pathologyDiagRecordIndex == 2){
							pageIndex.setPathologyDiag2Code(otherDiagCode);
							pageIndex.setPathologyDiag2Name(otherDiagName);
							pageIndex.setPathologyNumber2(pathologyNumber);
						}else if(pathologyDiagRecordIndex == 3){
							pageIndex.setPathologyDiag3Code(otherDiagCode);
							pageIndex.setPathologyDiag3Name(otherDiagName);
							pageIndex.setPathologyNumber3(pathologyNumber);
						}
					}

					List<Map<String, Object>> damageAndVenenationDiagRecords = (List<Map<String, Object>>)diseaseDiagInfo.get("damageAndVenenationDiagRecords");
					int damageAndVenenationDiagRecordIndex = 0;
					for (Map<String, Object> damageAndVenenationDiagRecord : damageAndVenenationDiagRecords) {
						damageAndVenenationDiagRecordIndex++;
						String otherDiagCode =  ObjectUtils.getStringValue(damageAndVenenationDiagRecord.get("diseaseDiagCode"));
						String otherDiagName =  ObjectUtils.getStringValue(damageAndVenenationDiagRecord.get("diseaseDiagName"));
						if(damageAndVenenationDiagRecordIndex == 1){
							pageIndex.setDamageAndVenenationDiag1Code(otherDiagCode);
							pageIndex.setDamageAndVenenationDiag1Name(otherDiagName);
						}else if(damageAndVenenationDiagRecordIndex == 2){
							pageIndex.setDamageAndVenenationDiag2Code(otherDiagCode);
							pageIndex.setDamageAndVenenationDiag2Name(otherDiagName);
						}else if(damageAndVenenationDiagRecordIndex == 3){
							pageIndex.setDamageAndVenenationDiag3Code(otherDiagCode);
							pageIndex.setDamageAndVenenationDiag3Name(otherDiagName);
						}
					}
				}
				Map<String, Object> operateInfo = (Map<String, Object>)jsonMap.get("hqmsOperateInfo");
				if(operateInfo != null){
					List<Map<String, Object>> operateRecords = (List<Map<String, Object>>)operateInfo.get("operateRecords");
					int operateRecordIndex = 0;
					for (Map<String, Object> operateRecord : operateRecords) {
						operateRecordIndex++;
						String surgeryCode = ObjectUtils.getStringValue(operateRecord.get("operateCode"));
						String surgeryName = ObjectUtils.getStringValue(operateRecord.get("operateName"));
						Date surgeryDateTime = ObjectUtils.getDateTimeValue(operateRecord.get("operateStartDate"));

						String surgeryLevelCode = ObjectUtils.getStringValue(operateRecord.get("opsLevelCode"));
						String surgeryLevelName = ObjectUtils.getStringValue(operateRecord.get("opsLevelName"));

						String surgeryBodyPartCodes = ObjectUtils.getStringValue(operateRecord.get("operateBodyPartCodes"));
						if(surgeryBodyPartCodes!=null){
							surgeryBodyPartCodes = surgeryBodyPartCodes.replaceAll("-", ",");
						}
						String surgeryBodyPartNames = ObjectUtils.getStringValue(operateRecord.get("operateBodyPartNames"));
						BigDecimal surgeryDurationTime =  ObjectUtils.getBigDecimalValue(operateRecord.get("operateDurationTime"));
						List<Map<String, Object>> operateWorkers = (List<Map<String, Object>>)operateRecord.get("operateWorkers");
						String workerA5001Name=null;
						String workerA5002Name=null;
						String workerA5003Name=null;
						String workerA5004Name=null;
						for (Map<String, Object> operateWorker : operateWorkers) {
							String professionTitleCode = ObjectUtils.getStringValue(operateWorker.get("professionTitleCode"));
							String workerName = ObjectUtils.getStringValue(operateWorker.get("medicalWorkerName"));
							if("A5001".equalsIgnoreCase(professionTitleCode)){
								workerA5001Name = workerName;
							}else if("A5002".equalsIgnoreCase(professionTitleCode)){
								workerA5002Name =  workerName;
							}else if("A5003".equalsIgnoreCase(professionTitleCode)){
								workerA5003Name =  workerName;
							}else if("A5004".equalsIgnoreCase(professionTitleCode)){
								workerA5004Name =  workerName;
							}
						}

						String anaesthesiaTypeCode = ObjectUtils.getStringValue(operateRecord.get("anaesthesiaTypeCode"));
						String anaesthesiaTypeName = ObjectUtils.getStringValue(operateRecord.get("anaesthesiaTypeName"));
						String anaesthesiaLevelCode = ObjectUtils.getStringValue(operateRecord.get("anaesthesiaLevelCode"));
						String anaesthesiaLevelName = ObjectUtils.getStringValue(operateRecord.get("anaesthesiaLevelName"));

						String incisionCicatrizeLevelCode = ObjectUtils.getStringValue(operateRecord.get("incisionCicatrizeLevelCode"));

						String incisionCicatrizeLevelName = ObjectUtils.getStringValue(operateRecord.get("incisionCicatrizeLevelName"));
						if(operateRecordIndex == 1){
							pageIndex.setSurgery1Code(surgeryCode);
							pageIndex.setSurgery1DateTime(surgeryDateTime);
							pageIndex.setSurgery1LevelCode(surgeryLevelCode);
							pageIndex.setSurgery1Name(surgeryName);
							pageIndex.setSurgery1BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery1DurationTime(surgeryDurationTime);
							pageIndex.setSurgery1A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery1A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery1A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery1A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery1AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery1AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery1IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 2){
							pageIndex.setSurgery2Code(surgeryCode);
							pageIndex.setSurgery2DateTime(surgeryDateTime);
							pageIndex.setSurgery2LevelCode(surgeryLevelCode);
							pageIndex.setSurgery2Name(surgeryName);
							pageIndex.setSurgery2BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery2DurationTime(surgeryDurationTime);
							pageIndex.setSurgery2A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery2A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery2A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery2A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery2AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery2AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery2IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 3){
							pageIndex.setSurgery3Code(surgeryCode);
							pageIndex.setSurgery3DateTime(surgeryDateTime);
							pageIndex.setSurgery3LevelCode(surgeryLevelCode);
							pageIndex.setSurgery3Name(surgeryName);
							pageIndex.setSurgery3BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery3DurationTime(surgeryDurationTime);
							pageIndex.setSurgery3A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery3A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery3A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery3A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery3AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery3AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery3IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 4){
							pageIndex.setSurgery4Code(surgeryCode);
							pageIndex.setSurgery4DateTime(surgeryDateTime);
							pageIndex.setSurgery4LevelCode(surgeryLevelCode);
							pageIndex.setSurgery4Name(surgeryName);
							pageIndex.setSurgery4BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery4DurationTime(surgeryDurationTime);
							pageIndex.setSurgery4A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery4A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery4A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery4A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery4AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery4AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery4IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 5){
							pageIndex.setSurgery5Code(surgeryCode);
							pageIndex.setSurgery5DateTime(surgeryDateTime);
							pageIndex.setSurgery5LevelCode(surgeryLevelCode);
							pageIndex.setSurgery5Name(surgeryName);
							pageIndex.setSurgery5BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery5DurationTime(surgeryDurationTime);
							pageIndex.setSurgery5A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery5A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery5A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery5A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery5AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery5AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery5IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 6){
							pageIndex.setSurgery6Code(surgeryCode);
							pageIndex.setSurgery6DateTime(surgeryDateTime);
							pageIndex.setSurgery6LevelCode(surgeryLevelCode);
							pageIndex.setSurgery6Name(surgeryName);
							pageIndex.setSurgery6BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery6DurationTime(surgeryDurationTime);
							pageIndex.setSurgery6A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery6A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery6A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery6A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery6AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery6AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery6IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 7){
							pageIndex.setSurgery7Code(surgeryCode);
							pageIndex.setSurgery7DateTime(surgeryDateTime);
							pageIndex.setSurgery7LevelCode(surgeryLevelCode);
							pageIndex.setSurgery7Name(surgeryName);
							pageIndex.setSurgery7BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery7DurationTime(surgeryDurationTime);
							pageIndex.setSurgery7A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery7A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery7A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery7A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery7AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery7AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery7IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 8){
							pageIndex.setSurgery8Code(surgeryCode);
							pageIndex.setSurgery8DateTime(surgeryDateTime);
							pageIndex.setSurgery8LevelCode(surgeryLevelCode);
							pageIndex.setSurgery8Name(surgeryName);
							pageIndex.setSurgery8BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery8DurationTime(surgeryDurationTime);
							pageIndex.setSurgery8A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery8A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery8A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery8A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery8AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery8AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery8IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 9){
							pageIndex.setSurgery9Code(surgeryCode);
							pageIndex.setSurgery9DateTime(surgeryDateTime);
							pageIndex.setSurgery9LevelCode(surgeryLevelCode);
							pageIndex.setSurgery9Name(surgeryName);
							pageIndex.setSurgery9BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery9DurationTime(surgeryDurationTime);
							pageIndex.setSurgery9A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery9A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery9A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery9A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery9AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery9AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery9IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}else if(operateRecordIndex == 10){
							pageIndex.setSurgery10Code(surgeryCode);
							pageIndex.setSurgery10DateTime(surgeryDateTime);
							pageIndex.setSurgery10LevelCode(surgeryLevelCode);
							pageIndex.setSurgery10Name(surgeryName);
							pageIndex.setSurgery10BodyPartCodes(surgeryBodyPartCodes);
							pageIndex.setSurgery10DurationTime(surgeryDurationTime);
							pageIndex.setSurgery10A5001DoctorName(workerA5001Name);
							pageIndex.setSurgery10A5002DoctorName(workerA5002Name);
							pageIndex.setSurgery10A5003DoctorName(workerA5003Name);
							pageIndex.setSurgery10A5004DoctorName(workerA5004Name);
							pageIndex.setSurgery10AnaesthesiaLevelCode(anaesthesiaLevelCode);
							pageIndex.setSurgery10AnaesthesiaTypeCode(anaesthesiaTypeCode);
							pageIndex.setSurgery10IncisionCicatrizeLevelCode(incisionCicatrizeLevelCode);
						}

					}
				}

				Map<String, Object> infectionInfo = (Map<String, Object>)jsonMap.get("infectionInfo");
				if(infectionInfo != null){
					Integer infectionTotalTimes =ObjectUtils.getIntegerValue(infectionInfo.get("infectionTotalTimes"));
					pageIndex.setInfectionTotalTimes(infectionTotalTimes);
				}
				Map<String, Object> intensiveCareInfo = (Map<String, Object>)jsonMap.get("intensiveCareInfo");
				if(intensiveCareInfo != null){
					List<Map<String, Object>> intensiveCareRecords = (List<Map<String, Object>>)intensiveCareInfo.get("intensiveCareRecords");
					int intensiveCareRecordIndex = 0;
					for (Map<String, Object> intensiveCareRecord : intensiveCareRecords) {
						intensiveCareRecordIndex++;
						String intensiveCareTypeName =ObjectUtils.getStringValue(intensiveCareRecord.get("icuTypeName"));
						String intensiveCareTypeCode =ObjectUtils.getStringValue(intensiveCareRecord.get("icuTypeCode"));
						Date intensiveCareEnterDateTime = ObjectUtils.getDateTimeValue(intensiveCareRecord.get("inIcuDateTime"));
						Date intensiveCareExitDateTime = ObjectUtils.getDateTimeValue(intensiveCareRecord.get("outIcuDateTime"));

						if(intensiveCareRecordIndex == 1){
							pageIndex.setIntensiveCare1TypeCode(intensiveCareTypeCode);
							pageIndex.setIntensiveCare1EnterDateTime(intensiveCareEnterDateTime);
							pageIndex.setIntensiveCare1ExitDateTime(intensiveCareExitDateTime);
						}else if(intensiveCareRecordIndex == 2){
							pageIndex.setIntensiveCare2TypeCode(intensiveCareTypeCode);
							pageIndex.setIntensiveCare2EnterDateTime(intensiveCareEnterDateTime);
							pageIndex.setIntensiveCare2ExitDateTime(intensiveCareExitDateTime);
						}else if(intensiveCareRecordIndex == 3){
							pageIndex.setIntensiveCare3TypeCode(intensiveCareTypeCode);
							pageIndex.setIntensiveCare3EnterDateTime(intensiveCareEnterDateTime);
							pageIndex.setIntensiveCare3ExitDateTime(intensiveCareExitDateTime);
						}else if(intensiveCareRecordIndex == 4){
							pageIndex.setIntensiveCare4TypeCode(intensiveCareTypeCode);
							pageIndex.setIntensiveCare4EnterDateTime(intensiveCareEnterDateTime);
							pageIndex.setIntensiveCare4ExitDateTime(intensiveCareExitDateTime);
						}else if(intensiveCareRecordIndex == 5){
							pageIndex.setIntensiveCare5TypeCode(intensiveCareTypeCode);
							pageIndex.setIntensiveCare5EnterDateTime(intensiveCareEnterDateTime);
							pageIndex.setIntensiveCare5ExitDateTime(intensiveCareExitDateTime);
						}
					}
				}

				Map<String, Object> nurseInfo = (Map<String, Object>)jsonMap.get("nurseInfo");
				if(nurseInfo != null){
					Integer specialNurseDayNumber = ObjectUtils.getIntegerValue(nurseInfo.get("specialNurseDayNumber"));
					pageIndex.setSpecialNurseDayNumber(specialNurseDayNumber);
					Integer firstLevelNurseDayNumber = ObjectUtils.getIntegerValue(nurseInfo.get("firstLevelNurseDayNumber"));
					pageIndex.setFirstLevelNurseDayNumber(firstLevelNurseDayNumber);
					Integer secondLevelNurseDayNumber = ObjectUtils.getIntegerValue(nurseInfo.get("secondLevelNurseDayNumber"));
					pageIndex.setSecondLevelNurseDayNumber(secondLevelNurseDayNumber);
					Integer threeLevelNurseDayNumber = ObjectUtils.getIntegerValue(nurseInfo.get("threeLevelNurseDayNumber"));
					pageIndex.setThirdLevelNurseDayNumber(threeLevelNurseDayNumber);
				}

				Map<String, Object> transferDeptInfo = (Map<String, Object>)jsonMap.get("transferDeptInfo");
				if(transferDeptInfo != null){
					List<Map<String, Object>> transferDeptRecords = (List<Map<String, Object>>)transferDeptInfo.get("transferDeptRecords");
					StringBuilder changeDeptCodes = new StringBuilder();
					for (Map<String, Object> transferDeptRecord : transferDeptRecords) {
						String transferInDeptCode = ObjectUtils.getStringValue(transferDeptRecord.get("inDeptCode"));
						if(transferInDeptCode!= null){
							if(changeDeptCodes.length() > 0 ){
								changeDeptCodes.append(","+transferInDeptCode);
							}else{
								changeDeptCodes.append(transferInDeptCode);
							}
						}

					}
					if(changeDeptCodes.length() > 0 ){
						pageIndex.setChangeDeptCodes(changeDeptCodes.toString());
					}
				}
				Map<String, Object> drugAllergyInfo = (Map<String, Object>)jsonMap.get("drugAllergyInfo");
				if(drugAllergyInfo != null){
					List<Map<String, Object>> drugAllergyRecords = (List<Map<String, Object>>)drugAllergyInfo.get("drugAllergyRecords");
					StringBuilder allergySourceCodes = new StringBuilder();
					StringBuilder drugAllergyNames = new StringBuilder();
					for (Map<String, Object> drugAllergyRecord : drugAllergyRecords) {
						String allergySourceCode = ObjectUtils.getStringValue(drugAllergyRecord.get("drugAllergyTypeCode"));
						String drugAllergyName = ObjectUtils.getStringValue(drugAllergyRecord.get("drugAllergyName"));

						if(allergySourceCode!= null){
							if(allergySourceCodes.length() > 0 ){
								allergySourceCodes.append(","+allergySourceCode);
							}else{
								allergySourceCodes.append(allergySourceCode);
							}
						}

						if(drugAllergyName!= null){
							if(drugAllergyNames.length() > 0 ){
								drugAllergyNames.append(","+drugAllergyName);
							}else{
								drugAllergyNames.append(drugAllergyName);
							}
						}

					}
					if(allergySourceCodes.length() > 0 ){
						pageIndex.setAllergySourceCodes(allergySourceCodes.toString());
					}
					if(drugAllergyNames.length() > 0 ){
						pageIndex.setAllergyDrugNames(drugAllergyNames.toString());
					}
				}

				Map<String, Object> infusionBloodInfo = (Map<String, Object>)jsonMap.get("infusionBloodInfo");
				if(infusionBloodInfo != null){
					List<Map<String, Object>> infusionBloodRecords = (List<Map<String, Object>>)infusionBloodInfo.get("infusionBloodRecords");
					StringBuilder isBleedingReactionCodes = new StringBuilder();
					BigDecimal redBloodCellTotalVolume = BigDecimal.ZERO;
					BigDecimal bloodPlateletTotalVolume = BigDecimal.ZERO;
					Integer plasmaTotalVolume = new Integer(0);
					Integer wholeBloodTotalVolume = new Integer(0);
					Integer selfBloodTotalVolume = new Integer(0);
					Integer otherBloodTotalVolume = new Integer(0);
					for (Map<String, Object> infusionBloodRecord : infusionBloodRecords) {
						String isBleedingReactionCode = ObjectUtils.getStringValue(infusionBloodRecord.get("isBleedingReactionCode"));
						if(isBleedingReactionCode != null){
							if(isBleedingReactionCodes.length()==0){
								isBleedingReactionCodes.append(isBleedingReactionCode);
							}
						}
						List<Map<String, Object>> infusionBloodElements = (List<Map<String, Object>>)infusionBloodRecord.get("infusionBloodElements");
						for (Map<String, Object> infusionBloodElement : infusionBloodElements) {
							String bloodElementCode = ObjectUtils.getStringValue(infusionBloodElement.get("bloodElementCode"));
							if("B0001".equalsIgnoreCase(bloodElementCode)){
								BigDecimal redBloodCellVolume = ObjectUtils.getBigDecimalValue(infusionBloodElement.get("bloodElementVolume"));
								if(redBloodCellVolume!= null){
									redBloodCellTotalVolume = redBloodCellTotalVolume.add(redBloodCellVolume);
								}
							}else if("B0003".equalsIgnoreCase(bloodElementCode)){
								BigDecimal bloodPlateletVolume = ObjectUtils.getBigDecimalValue(infusionBloodElement.get("bloodElementVolume"));
								if(bloodPlateletVolume!= null){
									bloodPlateletTotalVolume = bloodPlateletTotalVolume.add(bloodPlateletVolume);
								}
							}else if("B0004".equalsIgnoreCase(bloodElementCode)){
								Integer plasmaVolume = ObjectUtils.getIntegerValue(infusionBloodElement.get("bloodElementVolume"));
								if(plasmaVolume!= null){
									plasmaTotalVolume = plasmaTotalVolume+plasmaVolume;
								}
							}else if("B0005".equalsIgnoreCase(bloodElementCode)){
								Integer wholeBloodVolume = ObjectUtils.getIntegerValue(infusionBloodElement.get("bloodElementVolume"));
								if(wholeBloodVolume!= null){
									wholeBloodTotalVolume = wholeBloodTotalVolume+wholeBloodVolume;
								}
							}else if("B0006".equalsIgnoreCase(bloodElementCode)){
								Integer selfBloodVolume = ObjectUtils.getIntegerValue(infusionBloodElement.get("bloodElementVolume"));
								if(selfBloodVolume!= null){
									selfBloodTotalVolume = selfBloodTotalVolume+selfBloodVolume;
								}
							}else if("B9999".equalsIgnoreCase(bloodElementCode)){
								Integer otherBloodVolume = ObjectUtils.getIntegerValue(infusionBloodElement.get("bloodElementVolume"));
								if(otherBloodVolume!= null){
									otherBloodTotalVolume = otherBloodTotalVolume+otherBloodVolume;
								}
							}

						}
					}
					if(redBloodCellTotalVolume.compareTo(BigDecimal.ZERO) > 0){
						pageIndex.setRedBloodCellVolume(redBloodCellTotalVolume);
					}
					if(bloodPlateletTotalVolume.compareTo(BigDecimal.ZERO) > 0){
						pageIndex.setBloodPlateletVolume(bloodPlateletTotalVolume);
					}
					if(plasmaTotalVolume > 0){
						pageIndex.setPlasmaVolume(plasmaTotalVolume);
					}
					if(wholeBloodTotalVolume > 0){
						pageIndex.setWholeBloodVolume(wholeBloodTotalVolume);
					}
					if(selfBloodTotalVolume > 0){
						pageIndex.setSelfBloodVolume(selfBloodTotalVolume);
					}
					if(otherBloodTotalVolume > 0){
						pageIndex.setOtherBloodVolume(otherBloodTotalVolume);
					}

				}

				Map<String, Object> costInfo = (Map<String, Object>)jsonMap.get("costInfo");
				if(costInfo != null){
					BigDecimal totalCost = ObjectUtils.getBigDecimalValue(costInfo.get("totalCost"));
					pageIndex.setTotalCost(totalCost);
					BigDecimal selfCost =  ObjectUtils.getBigDecimalValue(costInfo.get("selfCost"));
					pageIndex.setSelfCost(selfCost);
					List<Map<String, Object>> costRecords = (List<Map<String, Object>>)costInfo.get("costRecords");
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = ObjectUtils.getStringValue(costRecord.get("medicalCostTypeCode"));
						BigDecimal costMoney =  ObjectUtils.getBigDecimalValue(costRecord.get("costMoney"));
						if(("C01001").equalsIgnoreCase(medicalCostTypeCode)){
							pageIndex.setC01001Cost(costMoney);
						}else if(("C01002").equalsIgnoreCase(medicalCostTypeCode)){
							pageIndex.setC01002Cost(costMoney);
						}else if(("C01003").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC01003Cost(costMoney);
						}else if(("C01999").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC01999Cost(costMoney);
						}else if(("C02001").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC02001Cost(costMoney);
						}else if(("C02002").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC02002Cost(costMoney);
						}else if(("C02003").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC02003Cost(costMoney);
						}else if(("C02004").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC02004Cost(costMoney);
						}else if(("C03001").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC03001Cost(costMoney);
						}else if(("C03002").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC03002Cost(costMoney);
						}else if(("C03003").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC03003Cost(costMoney);
						}else if(("C03004").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC03004Cost(costMoney);
						}else if(("C03005").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC03005Cost(costMoney);
						}else if(("C04001").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC04001Cost(costMoney);
						}else if(("C05001").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC05001Cost(costMoney);
						}else if(("C06001").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC06001Cost(costMoney);
						}else if(("C06002").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC06002Cost(costMoney);
						}else if(("C07001").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC07001Cost(costMoney);
						}else if(("C07002").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC07002Cost(costMoney);
						}else if(("C08001").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC08001Cost(costMoney);
						}else if(("C08002").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC08002Cost(costMoney);
						}else if(("C08003").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC08003Cost(costMoney);
						}else if(("C08004").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC08004Cost(costMoney);
						}else if(("C08005").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC08005Cost(costMoney);
						}else if(("C09001").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC09001Cost(costMoney);
						}else if(("C09002").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC09002Cost(costMoney);
						}else if(("C09003").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC09003Cost(costMoney);
						}else if(("C99999").equalsIgnoreCase((String)medicalCostTypeCode)){
							pageIndex.setC99999Cost(costMoney);
						}

					}
				}
			}
		}
		return pageIndexs;

	}

}
